
var alumnus = angular.module('alumnus', []);

var Combination = Class.extend({
	init : function(fields){
		this.fields = fields || []; 
		this.type = "";
	} , 
	addType : function(name) {
		var fields = this.fields;
		for (var i = 0 ; i < fields.length; i++) {
			if( name == fields[i].name) {
				this.type = fields[i].type;
			}
		}
	}
});

var CombinationFactory = Class.extend({
	init : function( options ) {
		this.instances = [];
		this.cond = {};
		this.options = options;
		this.instances.push(new Combination(options));
	} ,
	add : function(){
		this.instances.push(new Combination(this.options));
	}  , 
	minus : function(index , name) {
		delete this.cond[name];
		var ins = this.instances;
		this.instances = [];
		for(var i = 0 ; i < ins.length ; i++) {
			if( i != index) {
				this.instances.push(ins[i]);
			}
		}
	} ,
	// addType : function(ins , name){
	// 	var fields = ins.fields;
	// 	for (var i = 0 ; i < fields.length; i++) {
	// 		if( name == fields[i].name) {
	// 			ins.type = fields[i].type;
	// 		}
	// 	}
	// } ,
	change : function(event , name){
		this.cond[name] = event.target.value;
	}
});
 
function combinationFindIndexController($scope , $filter) {

	var fileds = [
		{ name : 'name' , title : '姓名' } ,
		{ name : 'usedName' , title : '曾用名' } ,
		{ name : 'origin' , title : '籍贯' } ,
		{ name : 'nation' , title : '民族' } ,
		{ name : 'politicalStatus' , title : '政治面貌' } ,
		{ name : 'location' , title : '所在地' } ,
		{ name : 'studentId' , title : '学号' } ,
		{ name : 'enrollmentTime' , title : '入学年份' } ,
		{ name : 'graduationTime' , title : '毕业年份' } ,
		{ name : 'department' , title : '院系' } ,
		{ name : 'major' , title : '专业' } ,
		{ name : 'className' , title : '班级' } ,
		{ name : 'educationQuality' , title : '学历' } ,
		{ name : 'degree' , title : '学位' } ,
		{ name : 'schoolingSpan' , title : '学制' } ,
		{ name : 'enrollType' , title : '培养方式' } ,
		{ name : 'companyName' , title : '单位名称' } ,
		{ name : 'companyType' , title : '单位性质' } ,
		{ name : 'industry' , title : '单位行业' } ,
		{ name : 'position' , title : '职务名称' } ,
		{ name : 'association' , title : '所属校友会' } ,
		{ name : 'position2' , title : '校友会职务' }
	];

	$scope.comb = new CombinationFactory(fileds);
	$scope.query = function(){
		console.log( $scope.comb.cond);
	}
}

